package com.clstu.utils;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * 测试自己攻击类的 select 操作
 */
public class JDBCUtilsUse2 {
    public static void main(String[] args) throws SQLException {
        Connection connection = JDBCUtils.getConnection();
        System.out.println(connection.getClass());//com.mysql.jdbc.JDBC4Connection
        String sql="select * from actor order by id";
        PreparedStatement preparedStatement = connection.prepareStatement(sql);
        ResultSet resultSet = preparedStatement.executeQuery();
        while (resultSet.next()){//打印结果
            System.out.println(resultSet.getInt("id")+"\t"+resultSet.getString("sex")+
                    "\t"+resultSet.getString("name")+"\t"+resultSet.getDate("birthday"));
        }
        JDBCUtils.close(resultSet,preparedStatement,connection);
    }
}
